//
//  UIBarButtonItem+Extension.swift
//  CYN微博
//
//  Created by chendada_ on 16/5/20.
//  Copyright © 2016年 chendada. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    convenience init(imageName:String,title:String? = nil,target:AnyObject?,action:Selector) {
       self.init()
        let btn = UIButton()
        //设置图片
        btn.setImage(UIImage(named: imageName), forState: .Normal)
          btn.setImage(UIImage(named: imageName+"_highlighted"), forState: .Highlighted)
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
      //设置颜色
        btn.setTitleColor(UIColor.darkGrayColor(), forState: .Normal)
        btn.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        btn.sizeToFit()
        
        
        //设置自定义视图
        self.customView = btn
    }

  
}
